<?php
class GrauAcademicosController extends AppController {

	var $name = 'GrauAcademicos';

	function index() {
		$this->GrauAcademico->recursive = 0;
		$this->set('grauAcademicos', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid grau academico', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('grauAcademico', $this->GrauAcademico->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->GrauAcademico->create();
			if ($this->GrauAcademico->save($this->data)) {
				$this->Session->setFlash(__('The grau academico has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The grau academico could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid grau academico', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->GrauAcademico->save($this->data)) {
				$this->Session->setFlash(__('The grau academico has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The grau academico could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->GrauAcademico->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for grau academico', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->GrauAcademico->delete($id)) {
			$this->Session->setFlash(__('Grau academico deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Grau academico was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
